﻿    //新建XMLHttpRequest对象实例
    var xmlHttp = false;
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      try
      {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (e) 
      {
        try 
        {
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e) 
        {
          xmlHttp = false;
        }
      }
    }
    if (!xmlHttp)
    {
       alert("Error initializing XMLHttpRequest!");
    }

    function SetCity(ddl)
    {
        var url="";
        var selectedText=ddl.options[ddl.selectedIndex].text;
        var selectedValue=ddl.options[ddl.selectedIndex].value;
        url="MyUserInfo.aspx?provinceId=" + selectedValue + "&random=" + new Date().getTime();
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = getCityList;
        xmlHttp.send(null);
    }
        
    function getCityList()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.status==200)
            {
                var ddlCity=document.getElementById("ctl00_ContentPlaceHolder1_Wizard1_CitySelect");
                RemoveAllFromSelect(ddlCity);
                var xmlDoc1=xmlHttp.responseXML;
                var xmlDoc=xmlHttp.responseXML.documentElement;
                var xmlList=xmlDoc.selectNodes("//city/cl");
                for(var i=0;i<xmlList.length;i++)
                {
                    var city=xmlDoc.getElementsByTagName("cl")[i].childNodes[0].nodeValue;
                    var ddlOption=new Option(city.split(',')[0],city.split(',')[1]);
                    ddlCity.options.add(ddlOption);
                }
                SetCounty(ddlCity);
            }
        }
    }
    
    function SetCounty(ddl)
    {
        var url="";
        var selectedText=ddl.options[ddl.selectedIndex].text;
        var selectedValue=ddl.options[ddl.selectedIndex].value;
        url="MyUserInfo.aspx?cityId=" + selectedValue + "&random=" + new Date().getTime();
        xmlHttp.open("GET",url,true);
        //回调函数
        xmlHttp.onreadystatechange = getCountyList;
        xmlHttp.send(null);
    }
    function getCountyList()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.status==200)
            {   
                var xmlDoc1=xmlHttp.responseXML;
                var xmlDoc=xmlHttp.responseXML.documentElement;
                var xmlList=xmlDoc.selectNodes("//county/ct");
                var ddlCounty=document.getElementById("ctl00_ContentPlaceHolder1_Wizard1_CountySelect");
                RemoveAllFromSelect(ddlCounty);
                for(var i=0;i<xmlList.length;i++)
                {
                    var county=xmlDoc.getElementsByTagName("ct")[i].childNodes[0].nodeValue;
                    var ddlOption=new Option(county.split(',')[0],county.split(',')[1]);
                    ddlCounty.options.add(ddlOption);
                }
            }
        }
    }
    function RemoveAllFromSelect(objSelect)
    {
        objSelect.options.length=0;
    }
    
    function SetCity1(ddl)
    {
        var url="";
        var selectedText=ddl.options[ddl.selectedIndex].text;
        var selectedValue=ddl.options[ddl.selectedIndex].value;
        url="ModifyUserAddr.aspx?provinceId=" + selectedValue + "&random=" + new Date().getTime();
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = getCityList1;
        xmlHttp.send(null);
    }
    
    function getCityList1()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.status==200)
            {
                var ddlCity=document.getElementById("ctl00_ContentPlaceHolder1_CitySelect");
                RemoveAllFromSelect(ddlCity);
                var xmlDoc1=xmlHttp.responseXML;
                var xmlDoc=xmlHttp.responseXML.documentElement;
                var xmlList=xmlDoc.selectNodes("//city/cl");
                for(var i=0;i<xmlList.length;i++)
                {
                    var city=xmlDoc.getElementsByTagName("cl")[i].childNodes[0].nodeValue;
                    var ddlOption=new Option(city.split(',')[0],city.split(',')[1]);
                    ddlCity.options.add(ddlOption);
                }
                SetCounty1(ddlCity);
            }
        }
    }
    
    function SetCounty1(ddl)
    {
        var url="";
        var selectedText=ddl.options[ddl.selectedIndex].text;
        var selectedValue=ddl.options[ddl.selectedIndex].value;
        url="ModifyUserAddr.aspx?cityId=" + selectedValue + "&random=" + new Date().getTime();
        xmlHttp.open("GET",url,true);
        //回调函数
        xmlHttp.onreadystatechange = getCountyList1;
        xmlHttp.send(null);
    }
    function getCountyList1()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.status==200)
            {   
                var xmlDoc1=xmlHttp.responseXML;
                var xmlDoc=xmlHttp.responseXML.documentElement;
                var xmlList=xmlDoc.selectNodes("//county/ct");
                var ddlCounty=document.getElementById("ctl00_ContentPlaceHolder1_CountySelect");
                RemoveAllFromSelect(ddlCounty);
                for(var i=0;i<xmlList.length;i++)
                {
                    var county=xmlDoc.getElementsByTagName("ct")[i].childNodes[0].nodeValue;
                    var ddlOption=new Option(county.split(',')[0],county.split(',')[1]);
                    ddlCounty.options.add(ddlOption);
                }
            }
        }
    }